package models;

import javax.persistence.Column;
import javax.persistence.Entity;

import play.data.validation.Email;
import play.data.validation.Required;
import play.db.jpa.Model;

/**
 * Class for table User.
 * @author Elisa
 */
@Entity
public class User extends Model {


	@Required
	@Column(unique = true)
	public String pseudo;
	public String name;
	public String firstname;
	@Email
	public String email;
	@Required
	public String password;
	@Required
	public boolean isAdmin;
	
	
	/**
	 * Default constructor.
	 * @param pseudo pseudo (user id)
	 * @param password password (md5)
	 */
	public User(String pseudo, String password){
		this.pseudo = pseudo;
		this.password = password;
		this.isAdmin = false;
	}
	
	/**
	 * Constructor with all fields.
	 * 
	 * @param pseudo pseudo (user id)
	 * @param name name
	 * @param firstname firstname
	 * @param email email
	 * @param password password (md5)
	 * @param isAdmin true if the user is an admin
	 */
	public User(String pseudo, String name, String firstname, String email, String password, boolean isAdmin) {
		this.pseudo = pseudo;
		this.name = name;
		this.firstname = firstname;
		this.email = email;
		this.password = password;
		this.isAdmin = isAdmin;
	}

}
